package avicit.bdp.dds.api.service;

import avicit.bdp.dds.dispatch.enums.CommandType;
import avicit.bdp.dds.dispatch.enums.FailureStrategy;
import avicit.bdp.dds.dispatch.enums.Priority;
import avicit.bdp.dds.dispatch.enums.RunMode;
import avicit.bdp.dds.dispatch.enums.TaskDependType;
import avicit.bdp.dds.common.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;

@Service
public class PlatformSyncService {

    @Autowired
    private ExecutorService execService;

    public void sync() {
        String processDefinitionId = "8a58a4aa83cada300183cc0c38f4008c";
        Integer failureStrategy = FailureStrategy.END.getCode();
        Integer execType = CommandType.START_PROCESS.getCode();
        Integer timeout = Constants.MAX_TASK_TIMEOUT;
        Integer taskDependType = TaskDependType.TASK_POST.getCode();
        Integer runMode = RunMode.RUN_MODE_SERIAL.getCode();
        Integer processInstancePriority = Priority.MEDIUM.getCode();
        try {
            execService.execProcessInstance(processDefinitionId, null, execType, failureStrategy, null,
                    taskDependType, null, null, runMode, processInstancePriority, null, timeout);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }

}
